<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>选项卡</title>
    <style>
        *{
            margin: 0px;
            padding: 0px;
            list-style: none;
        }
        div.current{
            display: block;
        }
        ul{
            overflow: hidden;
        }
        li{
            float: left;
            width:300px;
            cursor: pointer;
            height: 30px;
            line-height: 30px;
            text-align: center;
        }
        li.current{
            background:saddlebrown;
            color:violet;
        }
        div{
            width: 1300px;
            height: 250px;
            text-align: center;
            line-height: 300px;
            border:1px solid green;
            display: none;
        }
    </style>
</head>
<body>
    <ul>
        <li class="current">哔哩哔哩</li>
        <li>知乎</li>
        <li>新浪</li>
        <li>移动</li>
    </ul>
    <section>
        <div class="current"><img src="2.jpeg" height="250px" width="500px" alt=""></div>
        <div><img src="1.jpeg" height="250px" width="500px" alt=""></div>
        <div><img src="3.jpg" height="250px" width="500px" alt=""></div>
        <div><img src="4.jpeg" height="250px" width="500px" alt=""></div>
    </section>
    <script>
        var tags=document.getElementsByTagName('li');
        var boxs=document.getElementsByTagName('div');
        for(var k=0;k<tags.length;k++){
            tags[k].index=k;
            tags[k].onclick=function(){
                for(var p=0;p<tags.length;p++){
                    tags[p].className=''
                    boxs[p].className=''
                }
                this.className='current';
                var n=this.index;
                boxs[n].className='current'
            }
        }
    </script>
</body>
</html>